<?php
$productConfigView = array();
$configTable = new BPSheet('orderConfig');
if (isset($configId) && $configId > 0) {
    $config = $configTable->getListById($configId);
    $productConfigTable = new BPSheet('productConfig', $config);
    $productConfigView = $productConfigTable->getView();
}
?>
<fieldset>
    <table class="table table-hover">
        <thead>
            <tr>
                <th>
                    <input type="checkbox"  id="selectAll"> 
                </th>
                <th><?php echo '序号'; ?></th>
                <th><?php echo '产品名称'; ?></th>
                <th><?php echo '分类名称'; ?></th>
                <th><?php echo '产品编号'; ?></th>
                <th><?php echo '操作'; ?></th>
            </tr> 
        </thead>
        <tbody>
            <?php
            $serial = 0;
            foreach ($productConfigView as $config) {
                $configId = $config->getId();
                $serial++;
                $productId = '-';
                $categoryId = '-';
                $productName = '-';
                $productCode = '-';
                $productCode = '-';
                $categoryName = '-';
                if ($config->getItem('productId') instanceof BTreeItem) {
                    $productId = $config->getItem('productId')->getValue();
                    $productName = $config->getItem('productName')->getValue();
                    $productCode = $config->getItem('productCode')->getValue();
                }
                if ($config->getItem('categoryId') instanceof BTreeItem) {
                    $productId = $config->getItem('categoryId')->getValue();
                    $categoryName = $config->getItem('categoryName')->getValue();
                }
                ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="<?php echo $configId; ?>"> 
                        </label></td>
                    <td> <?php echo $serial; ?> </td>
                    <td> <?php echo $productName; ?> </td>   
                    <td> <?php echo $categoryName; ?> </td>   
                    <td> <?php echo $productCode; ?> </td>    
                    <td>
                        <div class="row-fluid">                         
                            <?php
                            echo $control->getAjaxLink(array('name' => '修改', 'id' => 'showAddProductConfig'), array(
                                'configId' => $configId,
                                    //'ajaxContainerId' => 'myModal',
                                    //'htmlOptions' => array(
                                    //'enctype' => 'multipart/form-data'),
                                    //'ajaxOptions' => array(
                                    //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
                            ));
                            echo " | ";
                            ?>                               
                            <?php
                            // echo $control->getAjaxLink(array('name' => '管理', 'id' => 'manageProduct'), array(
                            //'productId' => $productId,
                            // ));
                            ?> 
                            <?php
                            echo $control->getAjaxLink(array('name' => '删除', 'id' => 'deleteProductConfig'), array(
                                'configId' => $configId,
                            ));
                            ?> 
                        </div>                      
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>

    <div class="row-fluid">
        <?php
        echo $control->getAjaxLink(array('name' => '新增产品配置', 'id' => 'showAddProductConfig'), array(
            'productConfigId' => 0,
            'eventId' => $eventId,
            'configId' => $configId,
            //'pageContainerId' => $pageControl->getAjaxContainerId(),
            'htmlOptions' => array(
                //'enctype' => 'multipart/form-data',
                'class' => 'btn'),
                //'ajaxOptions' => array(
                //'complete' => 'function(){$("#ajax-loaderdiv").hide();$("#myModal").modal("show");}')
        ));
        ?>
        <?php
        echo $control->getAjaxLink(array('name' => '删除配置', 'id' => 'deleteProductConfig'), array(
            'htmlOptions' => array(
                'class' => 'btn',
            //'enctype' => 'multipart/form-data'
        )));
        ?>
    </div>   
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    </div>

    <div><input type="hidden" name="curPageNo" value="1"></div>

    <div class="pagination">  
        <ul>  
            <li class="active">
                <a href="javascript:void()">前一页</a>    </li>  
            <li class="active">
                <a href="javascript:void()">1</a>    </li>  
            <li class="active">
                <a href="javascript:void()">后一页</a>    </li>  
        </ul>  
    </div>
